package com.bbs.util;

import java.util.List;

import sun.nio.cs.ext.TIS_620;

/*
 * 分页工具  与访问数据库分离 只涉及算法
 * 输入：recordCount pageSize from to
 * 输出：start end
 * 把工具放到action 相关属性咋页面输出
 */
public class PageSplitUtil {
		//一页显示的记录数
		private int pageSize;
		
		//到第几页去
		private int toPage;
		
		//以哪一页为基准 在点下一页时有用
		private int fromPage;
		
		//当前页面  在页面上展示
		private int curPage;
		
		//总共几页
		private int totalPages;
		
		//记录总数
		private int recordCount;
		
		//sql 语句中的 limit start ,end
		private int start ,end;
		
		
		public PageSplitUtil(int pageSize, int toPage, int fromPage,
				int recordCount) {
			super();
			this.pageSize = pageSize;
			this.toPage = toPage;
			this.fromPage = fromPage;
			this.recordCount = recordCount;
			// mysql 能显示start+1 to end 条
			this.start=fromPage*pageSize;
			this.end=start+pageSize;
			this.totalPages=recordCount/pageSize;
		}
		
		public void comput(){
			this.start=fromPage*pageSize;
			this.end=start+pageSize;
			this.totalPages=recordCount/pageSize;
		}
		
		public int getPageSize() {
			return pageSize;
		}

		public void setPageSize(int pageSize) {
			this.pageSize = pageSize;
		}

		public int getToPage() {
			return toPage;
		}

		public void setToPage(int toPage) {
			this.toPage = toPage;
		}

		public int getFromPage() {
			return fromPage;
		}

		public void setFromPage(int fromPage) {
			this.fromPage = fromPage;
		}

		public int getCurPage() {
			return curPage;
		}

		public void setCurPage(int curPage) {
			this.curPage = curPage;
		}

		public int getTotalPages() {
			return totalPages;
		}

		public void setTotalPages(int totalPages) {
			this.totalPages = totalPages;
		}

		public int getRecordCount() {
			return recordCount;
		}

		public void setRecordCount(int recordCount) {
			this.recordCount = recordCount;
		}

		public int getStart() {
			return start;
		}

		public void setStart(int start) {
			this.start = start;
		}

		public int getEnd() {
			return end;
		}

		public void setEnd(int end) {
			this.end = end;
		}

	
}
